//package com.lepu.app.fun.mother_circle.adapter;
//
//import java.util.ArrayList;
//
//import android.annotation.SuppressLint;
//import android.content.Context;
//import android.content.Intent;
//import android.text.TextUtils;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.BaseAdapter;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//
//import com.app.application.MyApplication;
//import com.app.utils.Setting;
//import com.app.utils.Utils;
//import com.core.lib.utils.main.DateUtilBase;
//import com.core.lib.utils.photo.UniversalImageLoadTool;
//import com.core.lib.widget.CircularImageView;
//import com.eyzhs.app.R;
//import com.lepu.app.fun.mother_circle.fragment.FragmentMotherShow;
//import com.lepu.app.fun.my.PubContentDetailActivity;
//import com.lepu.app.fun.my.adapter.AdapterImage;
//import com.lepu.app.fun.my.bean.BeanPubContent;
//import com.lepu.app.fun.my.bean.BeanPubContentImage;
//import com.lepu.app.main.activity.MainTabActivity;
//import com.lepu.app.usercenter.bean.LoginInfo;
//import com.lepu.app.widget.ListViewForScrollview;
//
//public class AdapterMotherShow extends BaseAdapter {
//
//	private LayoutInflater mLayoutInflater = null;
//	private Context mContext = null;
//	private ArrayList<BeanPubContent> mArrayList = null;
//
//	public AdapterMotherShow(Context context,
//			ArrayList<BeanPubContent> arrayList) {
//		mContext = context;
//		mLayoutInflater = LayoutInflater.from(context);
//		mArrayList = arrayList;
//	}
//
//	@Override
//	public int getCount() {
//		int size = 0;
//		if (mArrayList != null && mArrayList.size() > 0) {
//			size = mArrayList.size();
//		}
//		return size;
//	}
//
//	@Override
//	public Object getItem(int position) {
//		return position;
//	}
//
//	@Override
//	public long getItemId(int position) {
//		return position;
//	}
//
//	@SuppressLint("InflateParams")
//	@Override
//	public View getView(final int position, View convertView, ViewGroup parent) {
//
//		final ViewHolder holder;
//
//		if (convertView == null) {
//			convertView = mLayoutInflater.inflate(
//					R.layout.mother_show_listitem, null);
//
//			holder = new ViewHolder();
//
//			LinearLayout mainItemLayout = (LinearLayout) convertView
//					.findViewById(R.id.mainItemLayout);
//			CircularImageView iconImageView = (CircularImageView) convertView
//					.findViewById(R.id.iconImageView);
//			TextView titleTextView = (TextView) convertView
//					.findViewById(R.id.titleTextView);
//			TextView subTitleTextView = (TextView) convertView
//					.findViewById(R.id.subTitleTextView);
//			TextView pubTimeTextView = (TextView) convertView
//					.findViewById(R.id.pubTimeTextView);
//
//			LinearLayout likeLayout = (LinearLayout) convertView
//					.findViewById(R.id.likeLayout);
//			TextView likeCountTextView = (TextView) convertView
//					.findViewById(R.id.likeCountTextView);
//			LinearLayout commentLayout = (LinearLayout) convertView
//					.findViewById(R.id.commentLayout);
//			TextView commentCountTextView = (TextView) convertView
//					.findViewById(R.id.commentCountTextView);
//			
//			ListViewForScrollview itemListView = (ListViewForScrollview) convertView.findViewById(R.id.itemListView);
//			LinearLayout deleteTopicLayout = (LinearLayout) convertView.findViewById(R.id.deleteTopicLayout);
//
//			holder.mainItemLayout = mainItemLayout;
//			holder.iconImageView = iconImageView;
//			holder.titleTextView = titleTextView;
//			holder.subTitleTextView = subTitleTextView;
//			holder.pubTimeTextView = pubTimeTextView;
//
//			holder.likeLayout = likeLayout;
//			holder.likeCountTextView = likeCountTextView;
//			holder.commentLayout = commentLayout;
//			holder.commentCountTextView = commentCountTextView;
//			
//			holder.itemListView = itemListView;
//			holder.deleteTopicLayout = deleteTopicLayout;
//
//			convertView.setTag(holder);
//		} else {
//			holder = (ViewHolder) convertView.getTag();
//		}
//		
//		holder.mainItemLayout.setTag(position);
//
//		final BeanPubContent item = mArrayList.get(position);
//
////		holder.iconImageView.setImageBitmap(ImageUtilBase.getBitmapByResId(
////				mContext, R.drawable.default_icon_small));
////		if (!TextUtils.isEmpty(item.UserAvatar)) {
////			String fileName = EncodeMD5.getMd5(item.UserAvatar);
////			String filePath = SdLocal.getCacheImagePath(mContext, 
////					fileName);
////			String imageUrl = Setting.getImageUrl(item.UserAvatar);
////
////			BitmapManager.getInstance().loadBitmap(imageUrl, filePath,
////					holder.iconImageView, true);
////		}
//		String imageUrl = Setting.getImageUrl(item.UserAvatar);
//		UniversalImageLoadTool.disPlay(imageUrl, holder.iconImageView, R.drawable.default_icon_small);
//
//		if(!TextUtils.isEmpty(item.BabyBirthDate))
//		{
//			String formatString = Utils.getBabyString(item.BabyBirthDate);
//			holder.titleTextView.setText(item.UserNickName+formatString);
//		}else{
//			holder.titleTextView.setText(item.UserNickName);
//		}
//		
//		holder.subTitleTextView.setText(item.TopicDescription);
//		holder.pubTimeTextView.setText(DateUtilBase
//				.friendly_time(item.RecordCreateTime));
//
//		holder.likeCountTextView.setText(item.FavourCount);
//		holder.commentCountTextView.setText(item.ReplyCount);
//
//		if(item.HasFavour.equals("0"))
//		{
//			//未赞
//			holder.likeLayout.setSelected(false);
//		}else
//		{
//			holder.likeLayout.setSelected(true);
//		}
//		
//		if(MyApplication.getInstance().checkIsLogin())
//		{
//			LoginInfo loginInfo = MyApplication.getInstance().getLoginInfo();
//			if(item.UserID.equals(loginInfo.UserID))
//			{
//				holder.deleteTopicLayout.setVisibility(View.VISIBLE);
//				holder.deleteTopicLayout.setOnClickListener(new View.OnClickListener() {
//					
//					@Override
//					public void onClick(View v) {
//						FragmentMotherShow.getInstance().deleteItem(position);
//					}
//				});
//			}else{
//				holder.deleteTopicLayout.setVisibility(View.GONE);
//			}
//		}else{
//			holder.deleteTopicLayout.setVisibility(View.GONE);
//		}
//		
//		holder.likeLayout.setOnClickListener(new View.OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//
//				FragmentMotherShow instance = FragmentMotherShow.getInstance();
//				if (instance != null) {
//					
//					instance.setCurrentItemIndex(position);
//					instance.requestLike(holder.likeLayout,
//							holder.likeCountTextView, item.TopicID);
//				}
//
//			}
//		});
//		holder.mainItemLayout.setOnClickListener(new View.OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//				
//				FragmentMotherShow.getInstance().setCurrentItemIndex(position);
//				
//				Intent intent = new Intent(mContext,
//						PubContentDetailActivity.class);
//				intent.putExtra("tag", 0);
//				intent.putExtra("TopicId", item.TopicID);
//				MainTabActivity.getInstance().startActivity(intent, true);
//			}
//		});
//		
//		if(item.MediaList != null && item.MediaList.size() > 0)
//		{
//			holder.itemListView.setVisibility(View.VISIBLE);
//			ArrayList<BeanPubContentImage> dataList = new ArrayList<BeanPubContentImage>();
//			for(int i=0;i<item.MediaList.size();i++)
//			{
//				BeanPubContentImage temp = item.MediaList.get(i);
//				if(temp.MediaType.equals("1"))
//				{
//					dataList.add(temp);
//				}
//			}
//			
//			if(dataList != null && dataList.size() > 0)
//			{
//				holder.itemListView.setAdapter(new AdapterImage(mContext, dataList));
//			}
//		}else{
//			holder.itemListView.setVisibility(View.GONE);
//		}
//
//		return convertView;
//	}
//
//	@SuppressWarnings("unused")
//	private static class ViewHolder {
//
//		LinearLayout mainItemLayout;
//		CircularImageView iconImageView;
//		TextView titleTextView;
//		TextView subTitleTextView;
//		TextView pubTimeTextView;
//
//		LinearLayout likeLayout;
//		TextView likeCountTextView;
//		
//		LinearLayout commentLayout;
//		TextView commentCountTextView;
//		
//		ListViewForScrollview itemListView;
//		LinearLayout deleteTopicLayout;
//	}
//}
